/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.isd.pool.modelo;

import com.isd.inventario.modelo.Producto;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author ctrosch
 */
@Entity
@Table(name = "USR_POOLPK")
@IdClass(ItemPickingPK.class)
public class ItemPicking implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "USR_POOLPK_POOL_NRPOOL")
    private int nrpool;

    @Id
    @Column(name = "USR_POOLPK_NORDEN")
    private int norden;

    //Pool
    @ManyToOne
    @JoinColumn(name = "USR_POOLPK_POOL_NRPOOL", referencedColumnName = "USR_POOL_NRPOOL", nullable = false, insertable=false, updatable=false)
    private Pool pool;
            
    @JoinColumns({
    @JoinColumn(name = "USR_POOLPK_TIPPRO", referencedColumnName = "STMPDH_TIPPRO", nullable = false),
    @JoinColumn(name = "USR_POOLPK_ARTCOD", referencedColumnName = "STMPDH_ARTCOD", nullable = false)
    })
    @ManyToOne
    private Producto producto;

    @Lob
    @Column(name = "USR_POOLPK_TEXTOS")
    private String observaciones;

    @Column(name = "USR_POOLPK_CANTID")
    private int cantid;

    @Column(name = "USR_PO_FECALT")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecalt;

    @Column(name = "USR_PO_FECMOD")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecmod;

    @Column(name = "USR_PO_USERID")
    private String userid;

    @Column(name = "USR_PO_ULTOPR")
    private String ultopr;

    @Column(name = "USR_PO_DEBAJA")
    private String debaja;

    @Column(name = "USR_PO_OALIAS")
    private String oalias;
    
    
    @Transient
    private int cantidadMaxima;

    public ItemPicking() {

        this.fecalt = new Date();
        this.fecmod = new Date();
        this.userid = "TV";
        this.ultopr = "A";
        this.debaja = "N";
        this.oalias = "USR_POOLPK";        
    }

    public ItemPicking(int nrpool, int norden) {

        this.nrpool = nrpool;
        this.norden = norden;
        this.fecalt = new Date();
        this.fecmod = new Date();
        this.userid = "TV";
        this.ultopr = "A";
        this.debaja = "N";
        this.oalias = "USR_POOLPK";    
    }

    public int getCantid() {
        return cantid;
    }

    public void setCantid(int cantid) {
        this.cantid = cantid;
    }

    public String getDebaja() {
        return debaja;
    }

    public void setDebaja(String debaja) {
        this.debaja = debaja;
    }

    public String getUltopr() {
        return ultopr;
    }

    public void setUltopr(String ultopr) {
        this.ultopr = ultopr;
    }
    
    public Date getFecalt() {
        return fecalt;
    }

    public void setFecalt(Date fecalt) {
        this.fecalt = fecalt;
    }

    public Date getFecmod() {
        return fecmod;
    }

    public void setFecmod(Date fecmod) {
        this.fecmod = fecmod;
    }

    public int getNorden() {
        return norden;
    }

    public void setNorden(int norden) {
        this.norden = norden;
    }

    public int getNrpool() {
        return nrpool;
    }

    public void setNrpool(int nrpool) {
        this.nrpool = nrpool;
    }

    public String getOalias() {
        return oalias;
    }

    public void setOalias(String oalias) {
        this.oalias = oalias;
    }

    public String getObservaciones() {
        return observaciones;
    }

    public void setObservaciones(String observaciones) {
        this.observaciones = observaciones;
    }
   
    public String getUserid() {
        return userid;
    }

    public void setUserid(String userid) {
        this.userid = userid;
    }

    public Pool getPool() {
        return pool;
    }

    public void setPool(Pool pool) {
        this.pool = pool;
    }
    
    
    public Producto getProducto() {
        return producto;
    }

    public void setProducto(Producto producto) {
        this.producto = producto;
    }

    public int getCantidadMaxima() {
        return cantidadMaxima;
    }

    public void setCantidadMaxima(int cantidadMaxima) {
        this.cantidadMaxima = cantidadMaxima;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ItemPicking other = (ItemPicking) obj;
        if (this.nrpool != other.nrpool) {
            return false;
        }
        if (this.norden != other.norden) {
            return false;
        }
        return true;
    }


    @Override
    public int hashCode() {
        int hash = 7;
        hash = 29 * hash + this.nrpool;
        hash = 29 * hash + this.norden;
        return hash;
    }

    @Override
    public String toString() {
        return "ItemPicking{" + "nrpool=" + nrpool + "norden=" + norden + '}';
    }

    


}
